//
//  WelfareH5CollectionViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/9/30.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "WelfareH5CollectionViewCell.h"

@interface WelfareH5CollectionViewCell ()

@property (strong, nonatomic) UIImageView *iconIV;
@property (strong, nonatomic) UILabel *titleL;
@property (strong, nonatomic) UILabel *desL;

@end

@implementation WelfareH5CollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        [self.contentView addSubview:self.iconIV];
        [self.contentView addSubview:self.titleL];
        [self.contentView addSubview:self.desL];
        
    }
    
    return self;

}

- (void)setH5Model:(WelfareH5Model *)H5Model {
    
    _H5Model = H5Model;
    
    [self.iconIV sd_setImageWithURL:[NSURL URLWithString:H5Model.qdphoto]];
    self.titleL.text = H5Model.title;
    self.desL.text = H5Model.describe;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    
    [self.iconIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(20));
        make.width.mas_equalTo(jisuan(130));
        make.height.mas_equalTo(jisuan(130));
    }];
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(weakSelf.iconIV.mas_top).with.offset(jisuan(30));
        make.left.mas_equalTo(weakSelf.iconIV.mas_right).with.offset(jisuan(20));
        
    }];
    [self.desL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(weakSelf.iconIV.mas_bottom).with.offset(-jisuan(24));
        make.left.mas_equalTo(weakSelf.iconIV.mas_right).with.offset(jisuan(20));
        
    }];
    
}

#pragma mark -lazy
- (UIImageView *)iconIV {
    
    if (!_iconIV) {
        
        _iconIV = [[UIImageView alloc] init];
        _iconIV.contentMode = UIViewContentModeScaleAspectFit;
    
    }
    
    return _iconIV;
}

- (UILabel *)titleL {
    
    if (!_titleL) {
        
        _titleL = [[UILabel alloc] init];
        _titleL.textColor = Color333333;
        _titleL.textAlignment = NSTextAlignmentLeft;
        _titleL.font = Font(30);
    }
    return _titleL;
}
- (UILabel *)desL {
    
    if (!_desL) {
        
        _desL = [[UILabel alloc] init];
        _desL.textColor = Color999999;
        _desL.textAlignment = NSTextAlignmentLeft;
        _desL.font = Font(24);
    }
    return _desL;
}

@end
